class Particle extends MyGameObject {
    constructor(playground, x, y, radius, speed, vx, vy, moveLength, color) {
        super();

        this.playground = playground;
        this.ctx = this.playground.gameMap.ctx;
        this.x = x;
        this.y = y;
        this.radius = radius;
        this.vx = vx;
        this.vy = vy;
        this.speed = speed;
        this.moveLength = moveLength;
        this.color = color;
        this.friction = 0.9;
        this.eps = 0.01;
    }


    start() {

    }

    update() {
        if (this.speed < this.eps || this.moveLength < this.eps) {
            this.destroy();
            return false;
        }
        let moved = Math.min(this.moveLength, this.speed * this.timeDelta / 1000)
        this.x += this.vx * moved;
        this.y += this.vy * moved;
        this.speed *= this.friction;
        this.moveLength -= moved;
        this.render();
    }

    render() {
        let scale = this.playground.scale
        this.ctx.beginPath();
        this.ctx.arc(this.x * scale, this.y * scale, this.radius * scale, 0, Math.PI * 2, false);
        this.ctx.fillStyle = this.color;
        this.ctx.fill();
    }
}